public class CInteger implements Integer {

  public static long count () { return ncount(); }

  public static long buffers () { return nbuffers(); }

  public CInteger (String src) throws Exception { _ref = nnew(src); }

  @Override
  public void release () throws Exception { ndelete(_ref); }

  @Override
  public int cmp (Integer other) throws Exception { return ncmp(_ref, ((CInteger)other)._ref); }

  @Override
  public Integer add (Integer other) throws Exception { return new CInteger(nadd(_ref, ((CInteger)other)._ref)); }

  @Override
  public Integer sub (Integer other) throws Exception { return new CInteger(nsub(_ref, ((CInteger)other)._ref)); }

  @Override
  public Integer mul (Integer other) throws Exception { return new CInteger(nmul(_ref, ((CInteger)other)._ref)); }

  @Override
  public Integer div (Integer other) throws Exception { return new CInteger(ndiv(_ref, ((CInteger)other)._ref)); }

  @Override
  public Integer mod (Integer other) throws Exception { return new CInteger(nmod(_ref, ((CInteger)other)._ref)); }

  @Override
  public Integer neg () throws Exception { return new CInteger(nneg(_ref)); }

  @Override
  public Integer abs () throws Exception { return new CInteger(nabs(_ref)); }

  @Override
  public Integer pow (int exp) throws Exception { return new CInteger(npow(_ref, exp)); }

  @Override
  public Meta meta () throws Exception { return nmeta(_ref); }


  private CInteger (long ref) { _ref = ref; }

  private static native long nnew (String src) throws Exception;
  private static native void ndelete (long ref) throws Exception;
  private static native int ncmp (long op1, long op2) throws Exception;
  private static native long nadd (long op1, long op2) throws Exception;
  private static native long nsub (long op1, long op2) throws Exception;
  private static native long nmul (long op1, long op2) throws Exception;
  private static native long ndiv (long op1, long op2) throws Exception;
  private static native long nmod (long op1, long op2) throws Exception;
  private static native long nneg (long ref) throws Exception;
  private static native long nabs (long ref) throws Exception;
  private static native long npow (long ref, int exp) throws Exception;
  private static native Meta nmeta (long ref) throws Exception;
  private static native long ncount ();
  private static native long nbuffers ();

  private long _ref;
}
